                <!-- table -->
				<div class="box">
					<!-- box / title -->
					<div class="title">
						<h5>
                            <?=$title;?>
                            <?php if($month!='-')
                                echo 'Periode '.month_name($month);
                            ?>
                        </h5>
						<div class="search">
                        <?php if($month!='-'): ?>
                            <?=form_open('billing-ar/daily_record/getVolumeExport')?>
								<div class="input">
                                    <label class="search"><?=lang('export')?></label>
									<?=form_dropdown('export',config('export'))?>
								</div>
								<div class="button">
									<?=form_submit('submit',lang('export'))?>
								</div>
							<?=form_close()?>
                        
                        <?php else:?>
                            <?=form_open('billing-ar/daily_record/getVolume')?>
								
                                <div class="input">
                                    <?=form_dropdown('month',config('month'),date('m'))?>
                                    <?=form_dropdown('year',config('year'),date('Y'))?>
								</div>
     
								<div class="button">
									<input type="submit" name="submit" value="Search" />
								</div>
							<?=form_close()?>
                         <?php endif;?>   
						</div>
					</div>
					<!-- end box / title -->
					<div class="table">
                    
                        <?php if($this->session->flashdata('success')):?>
						<div id="message-success" class="message message-success">
							<div class="image">
								<img src="resources/images/icons/success.png" alt="Success" height="32" />
							</div>
							<div class="text">
								<h6>Send Email</h6>
								<span>Send Email Success to Recipient , to Edit email set to Settings Menu !</span>
							</div>
							<div class="dismiss">
									<a href="#message-success"></a>
							</div>
						</div>
						<?php elseif($this->session->flashdata('error')):?>
						<div id="message-error" class="message message-error">
								<div class="image">
									<img src="resources/images/icons/error.png" alt="Error" height="32" />
								</div>
								<div class="text">
									<h6>Send Email</h6>
									<span>Send Email Error to Recipient , to Edit email set to Settings Menu !</span>
								</div>
								<div class="dismiss">
									<a href="#message-error"></a>
								</div>
						</div>
						<?php endif;?>
                        <?php
                            $i=1;
                            $tot_cust = 0;
                            foreach($custGroup  as $row_area):
                                $area[$i] = $row_area['CustomerGroup'];
                                $total[$i]= COUNT($this->customers->getAllCustomer('',$row_area['CustomerGroup'])); 
                                $tot_cust = $tot_cust + $total[$i];
                                $i++;
                            endforeach;
                            $n_customer = $tot_cust + 3; 
                        ?>
                       
						<table>
                            <thead>
                                <tr>
                				    <th style="vertical-align: middle;" rowspan="4">NO</th>
                				    <th style="vertical-align: middle;" rowspan="4">TGL</th>				
                 				    <th colspan="<?=$n_customer?>">CUSTOMER</th>				 
                			    </tr>
                                <tr>			 		
                   				<?php 
                                    for($m=1;$m<=$i;$m++):
                                        if($m<$i):
                                            $j = $total[$m];
                                ?>					
                     				   <th colspan="<?=$j+1?>"><?=$area[$m]?></th>
                                <?php
                                        endif;
                                    endfor;?>     				 							
                    				<th rowspan='2'>TOTAL</th>		
                    			</tr>
                                <tr>
                                <?php 
                    				for($n=1; $n<=$i; $n++):
                                        if($n<$i):
                        				    $Q=$this->customers->getAllCustomer('',$area[$n]);
                        					foreach($Q as $cust):
                      							print "<th>".$cust['KodePerusahaan']."</th>";				
                        					endforeach;
                      							print "<th>Sub Total</th>";	
                                         endif;         			
                    				endfor;?>
                    		 	</tr>
                                
                                <tr>
                                <?php 
                    				for($n=1; $n<=$i; $n++):
                                        if($n<$i):
                        				    $Q=$this->customers->getAllCustomer('',$area[$n]);
                        					foreach($Q as $cust):
                      							print "<th>Sm&sup3;</th>";				
                        					endforeach;
                      							print "<th>MMSCFD</th>";	
                                         endif;         			
                    				endfor;?>
                                    <th>MMSCFD</th>				
                    		 	</tr>
                            </thead>
                            <tbody>
                                <tr>
                    				<td colspan="2"><?=month_name($month)?></td>				
                     				<td colspan="<?=$n_customer?>"></td>				 
                    			</tr>
                                <?php 
                                $no=1;
                                $total_all=0;
                                $total_data = count($daily);
                                foreach($daily as $rec):?>
                                <?php if($rec['day_name']=='Sunday') 
                                    $class='class="sunday"';
                                  elseif($rec['day_name']=='Saturday')
                                    $class='class="saturday"';
                                  else
                                    $class='';   
                                ?>
                                 <tr>
                                    <td <?=$class?>><?=$no?></td>
                                    <td <?=$class?>><?=substr($rec['Date'],8,2);?></td>
                                     <?php 
                                        $totalx=0;
                                        for($n=1; $n<$i; $n++):
                                            $custData  = $this->customers->getAllCustomer('',$area[$n]);
                                            $total=0;
                                            $sub_total_flow = 0;
                                            foreach($custData as $rowCust):
                                            $evc = $this->gas->getDailyEvc($month,$year,$rowCust['CustID'],'',$rec['Date']);
                                                if(COUNT($evc))
                                                    $flowRate = number_format($evc['FlowRate'],3,'.',',');
                                                else
                                                    $flowRate = '0.000';
                                            
                                            $sub_total_flow= $sub_total_flow + $flowRate;
                                            
                                     ?>    
                    						<td <?=$class?>><?=$flowRate?></td>				
 					                  <?php endforeach;
                                       
                                       $x = $sub_total_flow  * 35.3147;
                                       $sub_total = $x/1000000;
                                       $total =$total + $sub_total;
                                       $s_total_all[$n]=$total;
                                       $totalx=$totalx+$total;
                                       $total_all=$total_all+$totalx;
                                       ?>
		                             <td <?=$class?>><?=number_format($sub_total,2,'.',',')?></td>				
            				       <?php endfor; ?>
                                   <td <?=$class?>><?=number_format($total,2,'.',',')?></td>
                                </tr>    									
                                <?php 
                                    $no++;
                                endforeach;?>
                                
                                <tr>
                    				<th colspan="2"><strong>Average</strong></th>
                    				<?php
                                    $avg_total=0;
                                    for($n=1;$n<$i;$n++):
                                        $Q=$this->customers->getAllCustomer('',$area[$n]);
                                        $avg_sub_total=0;
                                        foreach($Q as $rowCust2):
                                            $average = $this->gas->AverageGas('FlowRate',$month,$year,$rowCust2['CustID']);
                                            $avg = decimal($average['FlowRate'],3);
                                            if($avg)
                                                $avg = $avg;
                                            else
                                                $avg = '0.000';
                                       
                    				 ?>		
						              <td><strong><?=$avg?></td>				
                    				<?php
                                        endforeach;
                                       
                                       if(!empty($s_total_all[$n])): 
                        					if($s_total_all[$n]!=0)
                        						$avg_sub_total=$s_total_all[$n]/$total_data;
                                       endif;     
                   					  
                  					 ?>
                    							<td><strong><?=decimal($avg_sub_total,3)?></strong></td>				
                    				<?php	
                                         $avg_total=$avg_total+$avg_sub_total;		
                    				endfor; 
                                    ?>							
                    				<td><strong><?=decimal($avg_total,3)?></strong></td> 					
                    			</tr>
                                
                                <tr>
                    				<th style="vertical-align: middle;" colspan="2" rowspan="2"><strong>Total</strong></th>
                    				<?php 
                                        for($n=1; $n<$i; $n++):
                                            $custData  = $this->customers->getAllCustomer('',$area[$n]);
                                            $total=0;
                                            $sub_total_flow = 0;
                                            foreach($custData as $rowCust):
                                            $evc = $this->gas->getSUMDailyEvc('FlowRate',$month,$year,$rowCust['CustID']);
                                                if(COUNT($evc))
                                                    $flowRate = number_format($evc['FlowRate'],3,'.',',');
                                                else
                                                    $flowRate = '0.000';
                                            
                                            $sub_total_flow= $sub_total_flow + $flowRate;
                    				  ?>		
                    						
						              <td class="right"><strong><?=$flowRate?></strong></td>			
             					    <?php    
                                            endforeach;
                                    ?>
                                    <td><strong>
                                        <?php if(!empty($s_total_all[$n]))
                                                echo number_format($s_total_all[$n],2,'.',',') ?>
                                        </strong>
                                    </td>
                                    <?php
                                        endfor;
                                    ?>
           							
                    				<td><strong><?=number_format($total_all,2,'.',',')?></strong></td> 					
                    			</tr>
                                
                                <tr>
                                <?php 
                    				for($n=1; $n<=$i; $n++):
                                        if($n<$i):
                        				    $Q=$this->customers->getAllCustomer('',$area[$n]);
                        					foreach($Q as $cust):
                      							print "<th>".$cust['KodePerusahaan']."</th>";				
                        					endforeach;
                      							print "<th></th>";	
                                         endif;         			
                    				endfor;?>
                                    <th></th> 		
                    		 	</tr>
                                
                            </tbody>
                        </table>
                        
                        <?php if($month!='-'):?>
                        <div class="action">
                            <?=anchor('billing-ar/daily_record/getVolumeReset','Kembali Ke Awal');?>
			         	</div>
                        <?php endif;?>
                        
					</div>
				</div>
				<!-- end table -->